/*
 * @Author: sdq 483657864@qq.com
 * @Date: 2025-04-18 16:23:35
 * @LastEditors: sdq 483657864@qq.com
 * @LastEditTime: 2025-04-18 17:30:46
 * @FilePath: \ranyu_anchor_new\src\agroa\setRole\index.ts
 * @Description: 设置用户权限
 */
export const setClientRole = async () => {
  const { agoraClient } = await import("../index");
  const { useVoiceConfigStore } = await import("@/store");
  const voiceConfigStore = useVoiceConfigStore();
  const { handleError } = await import("../index");
  /**
   * 切换为主播角色
   * @description 需要重新设置客户端角色
   */
  const switchToHost = async () => {
    if (!agoraClient.value) return;
    try {
      await agoraClient.value.setClientRole("host");
      voiceConfigStore.SET_VOICE_CONFIG({ role: "host" });
      ElMessage.info("您现在是主播");
    } catch (error) {
      handleError("角色切换失败", error);
      throw error;
    }
  };
  return {
    switchToHost,
  };
};
